using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
/// <summary>
/// Summary description for ShoppingCart
/// </summary>
public class ShoppingCart
{
    public List<Item> ItemCollection = new List<Item>();

    public void Add(Item item)
    {
        for (int i = 0; i < ItemCollection.Count; i++)
        {
            if (item.IDProduct == ItemCollection[i].IDProduct)
            {
                ItemCollection[i].Quantity += item.Quantity;
                return;
            }
        }
        ItemCollection.Add(item);
    }
    public void Delete(Item item)
    {
        for (int i = 0; i < ItemCollection.Count; i++)
        {
            if (item.IDProduct == ItemCollection[i].IDProduct)
            {
                ItemCollection.RemoveAt(i);
                return;
            }
        }
    }
    public void Update(Item item)
    {
        
        for (int i = 0; i < ItemCollection.Count; i++)
        {
            if (item.IDProduct == ItemCollection[i].IDProduct)
            {
                ItemCollection[i].Quantity = item.Quantity;
                return;
            }
        }
    }
    public float tongtien()
    {
        float total = 0;
        for (int i = 0; i < ItemCollection.Count; i++)
        {
            total += float.Parse(ItemCollection[i].Price.ToString()) * float.Parse(ItemCollection[i].Quantity.ToString()); 
        }
        return total;
    }

    

}
